package com.project.controller;

import com.project.bean.ReplyBean;
import com.project.bean.UserBean;
import com.project.service.IReplyService;
import com.project.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("reply")
public class ReplyController {
    @Autowired
    private IReplyService replyService;

    @RequestMapping("add")
    public String add(String title, String content, Integer mainPostId,HttpServletRequest request){

        UserBean userBean = (UserBean) request.getSession().getAttribute("loginUser");

        ReplyBean replyBean = new ReplyBean(title,content, userBean.getId(), mainPostId);
        replyService.add(replyBean);
        return "ok";
    }

}
